home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
infor
/
tsptp.zip
/
TSBENCH.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-04-09
|
4KB
|
144 lines
(******************************************************************************)
(* TSBENCH.PAS *)
(* *)
(* Routines for internal timer used by the Pascal benchmarks. *)
(* *)
(******************************************************************************)
IMPLEMENTATION UNIT TSBench;
IMPORT Lib;
VAR
Hours,
Minutes,
Seconds,
Hundredths : WORD;
NullLoops,
BenchLoops : BmCounter;
NullLoopTime,
BenchLoopTime,
StartTime,
NullTime,
BenchTime : BmTimeT;
(** STARTTIMER ****************************************************************
*
* Synopsis:
*
* StartTimer;
*
* Description:
*
* StartTime starts the benchmark timer.
*)
PROCEDURE StartTimer;
BEGIN
Lib.GetTime(Hours, Minutes, Seconds, Hundredths);
StartTime := (((((Hours * 60)+Minutes)*60)+Seconds)*100)+Hundredths;
END;
(** NULLTIMESUP ***************************************************************
*
* Synopsis:
*
* NullTimesUp;
*
* Description:
*
* NullTimesUp stops the timer when the NULL timing loop is complete.
*)
FUNCTION NullTimesUp{: BOOLEAN};
BEGIN
Lib.GetTime(Hours, Minutes, Seconds, Hundredths);
NullTime := ((((((Hours * 60)+Minutes)*60)+Seconds)*100)+Hundredths)-StartTime;
NullLoops := NullLoops + 1;
NullTimesUp := (NullTime >= NullLoopTime);
END;
(** BENCHTIMESUP **************************************************************
*
* Synopsis:
*
* BenchTimesUp;
*
* Description:
*
* BenchTimesUp stops the timer when the NULL timing loop is complete.
*)
FUNCTION BenchTimesUp{: BOOLEAN};
BEGIN
Lib.GetTime(Hours, Minutes, Seconds, Hundredths);
BenchTime := ((((((Hours * 60)+Minutes)*60)+Seconds)*100)+Hundredths)-StartTime;
BenchLoops := BenchLoops + 1;
BenchTimesUp := (BenchTime >= BenchLoopTime);
END;
(** REPORTTIMES ***************************************************************
*
* Synopsis:
*
* ReportTimes;
*
* Description:
*
* ReportTimes reports the benchmark times and stats. Note that the
* calculated results for LoopOverhead, TotalTime and Loops per second
* are prone to any floating point errors. Therefore you may wish to
* check these results manually.
*)
PROCEDURE ReportTimes;
VAR
RLoopOverhead : REAL;
RTotalTime : REAL;
BEGIN
RLoopOverhead := (NullTime/NullLoops)*BenchLoops;
RTotalTime := BenchTime-RLoopOverhead;
WriteLn('Benchmark times in seconds');
WriteLn('NullTime : ', NullTime/100:0:2);
WriteLn('BenchTime : ', BenchTime/100:0:2);
WriteLn('Null loops : ', NullLoops);
WriteLn('Bench loops : ', BenchLoops);
WriteLn('LoopOverhead : ', RLoopOverhead/100:0:2);
WriteLn('TotalTime : ', RTotalTime/100:0:2);
WriteLn('Loops per second : ', BenchLoops/(RTotalTime/100):0:2);
END;
(** DUMMY *********************************************************************
*
* Synopsis:
*
* Dummy;
*
* Description:
*
* Dummy is a dummy procedure used to calculate the looping overhead in a
* benchmark. In order to prevent it being optimised out of existence it
* must introduce a side effect. In this case we modify the exported
* variable DummyVar.
*)
PROCEDURE Dummy;
BEGIN
DummyVar := NOT DummyVar
END;
BEGIN
NullLoopTime := MINNULLTIME*100;
BenchLoopTime := MINBENCHTIME*100;
NullLoops := 0;
BenchLoops := 0;
DummyVar := TRUE;
END.